package com.sjgs.gis.config;


import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;

@NoArgsConstructor
@ConfigurationProperties(prefix = "filesystem")
public class FileSystemProperties {
    private String rootDir = "E:/data/fs";
    private Integer writeRetry = 5;
    private Integer checkRetry = 2;
    private Long grpcChunkSize = 2097152L;
    private Long restChunkSize = 4194304L;
    private final FileSystemProperties.Hdfs hdfs = new FileSystemProperties.Hdfs();
    private final FileSystemProperties.Gridfs gridfs = new FileSystemProperties.Gridfs();

    public String getRootDir() {
        return rootDir;
    }

    public void setRootDir(String rootDir) {
        this.rootDir = rootDir;
    }

    public Integer getWriteRetry() {
        return writeRetry;
    }

    public void setWriteRetry(Integer writeRetry) {
        this.writeRetry = writeRetry;
    }

    public Integer getCheckRetry() {
        return checkRetry;
    }

    public void setCheckRetry(Integer checkRetry) {
        this.checkRetry = checkRetry;
    }

    public Long getGrpcChunkSize() {
        return grpcChunkSize;
    }

    public void setGrpcChunkSize(Long grpcChunkSize) {
        this.grpcChunkSize = grpcChunkSize;
    }

    public Long getRestChunkSize() {
        return restChunkSize;
    }

    public void setRestChunkSize(Long restChunkSize) {
        this.restChunkSize = restChunkSize;
    }

    public Hdfs getHdfs() {
        return hdfs;
    }

    public Gridfs getGridfs() {
        return gridfs;
    }

    @NoArgsConstructor
    public static class Hdfs {
        Boolean enabled = false;
        String url = "hdfs://localhost:9009";

        public Boolean getEnabled() {
            return enabled;
        }

        public void setEnabled(Boolean enabled) {
            this.enabled = enabled;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }

    @NoArgsConstructor
    public static class Gridfs {
        Boolean enabled = false;
        String bucket = "gis";
        String authenticationDatabase = "admin";
        String gridFsDatabase = "fs";
        String host = "127.0.0.1";
        Integer port = 27017;
        String username = "root";
        String password = "";
        String database = "fs";
        Integer maxSize = 10;
        Integer minSize = 5;


        public Boolean getEnabled() {
            return enabled;
        }

        public void setEnabled(Boolean enabled) {
            this.enabled = enabled;
        }

        public String getBucket() {
            return bucket;
        }

        public void setBucket(String bucket) {
            this.bucket = bucket;
        }

        public String getAuthenticationDatabase() {
            return authenticationDatabase;
        }

        public void setAuthenticationDatabase(String authenticationDatabase) {
            this.authenticationDatabase = authenticationDatabase;
        }

        public String getGridFsDatabase() {
            return gridFsDatabase;
        }

        public void setGridFsDatabase(String gridFsDatabase) {
            this.gridFsDatabase = gridFsDatabase;
        }

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public Integer getPort() {
            return port;
        }

        public void setPort(Integer port) {
            this.port = port;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getDatabase() {
            return database;
        }

        public void setDatabase(String database) {
            this.database = database;
        }

        public Integer getMaxSize() {
            return maxSize;
        }

        public void setMaxSize(Integer maxSize) {
            this.maxSize = maxSize;
        }

        public Integer getMinSize() {
            return minSize;
        }

        public void setMinSize(Integer minSize) {
            this.minSize = minSize;
        }
    }
}
